
$(function(){
	
	$("#usrform").validate({
    	rules: {
    		selshopes: {
				required: { depends: function () {
										if($(".list_search").find("input:checkbox").length > 0){
											if($(".list_search").find("input:checkbox:checked").length == 0)
												return true;
										}
						   			}
							}
			}
		},
		messages: {
			selshopes: {
				required: "<li>相談する店舗を選択してください（1店舗は必須項目です）</li>"
			}
		},
		errorPlacement: function (error, element) {
			var elmName = element.attr("name");
			
			if($("#shoperr").html().indexOf(error[0].innerHTML) < 0 )
				$("#shoperr").append(error[0].innerHTML);
		},
		ignore: []
    });
    
	$("#btnNext").click(function (evt) {
		
		$("#shoperr").empty();
		
    	if ($("#usrform").validate().form()) {
    		
    		document.usrform.action= "/search/requestsearch/confirm/";
    		document.usrform.submit();
        }
    	else
    	{
    		if($("#shoperr > *").length > 0){
    			$("#shoperr").show();
            	$("#shoptitle").addClass("error");
            }
    	}
    });

})


